<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2018/3/26
 * Time: 19:24
 */
class MyClass {
	const constant = 'constant value';

	function showConstant() {
		echo self::constant . "\n";
	}
}

//constant value
echo MyClass::constant . "\n";

$classname = "MyClass";
//constant value
echo $classname::constant . "\n"; // 自 5.3.0 起

$class = new MyClass();
//constant value
$class->showConstant();

//constant value
echo $class::constant."\n"; // 自 PHP 5.3.0 起
